home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / jaz_clib.arc / JAZLIB.DOC < prev    next >
Text File  |  1989-04-09  |  90KB  |  2,728 lines

  1. (c) JAZSOFT 1986 by Jack A. Zucker
  2.  
  3. If you are interested in getting support for these
  4. routines or are just feeling plain guilty for using them
  5. without paying for them, feel free to send a donation of
  6. whatever you can afford. ($25.00 would be appreciated).
  7. My address is:
  8.  
  9. JazSoft
  10. Jack A. Zucker
  11. 10318 Broom Lane
  12. Seabrook, Md. 20706
  13.  
  14. You may leave messages to me concerning problems, advice, etc on
  15. Robert Blacher's Computer Connections PCBoard in Washington, D.C. at
  16. (202) 547-2008 (2400/1200 baud).
  17. or if you are really desperate at my house at
  18.  
  19. (301) 794-5950 or
  20. (301) 794-8763.
  21.  
  22.  
  23. If you get my answering machine, Please leave a message and your phone
  24. number, but be forewarned... I will not call you long distance unless
  25. you tell me to call collect. Sorry about this but I called one guy and
  26. spent a half hour talking to him then found out he lived in Ontario,Ca.!!!!
  27. Thanks, and I hope you enjoy.
  28. -Jaz
  29.  
  30.  
  31.  
  32.  
  33.  
  34.                         DOS FUNCTIONS AND FILE HANDLING
  35.  
  36. 1. JZCLSFIL     Close a file handle
  37.  
  38.         This functions closes a previously opened file handle.
  39.  
  40.         werror = jzclsfil(whandle);
  41.  
  42.         int werror              -1 if an error occurred,
  43.                                  0 if everything went according to plan.
  44.  
  45.         int whandle             The opened file handle.
  46.  
  47. 2. JZCPYFIL     Copy a file
  48.  
  49.         This function copies one file spec to another file spec.
  50.         Wildcards may also be used in the file spec.
  51.  
  52.         jzcpyfil(wsource,wdestin);
  53.  
  54.         char *wsource           Source file specification
  55.  
  56.         char *wdestin           Destination file specification
  57.  
  58. 3. JZCRTFIL     Create a file handle
  59.  
  60.         This function creates a file handle or truncates an existing
  61.         one.
  62.  
  63.         werror = jzcrtfil(wname,wattr);
  64.  
  65.         int werror              -1 if an error occurred,
  66.                                  otherwise a valid dos file handle
  67.  
  68.         char *wname             File spec to create/truncate
  69.  
  70.         int wattr               File attribute to create file with.
  71.                                 0 or 32 is the normal file attribute.
  72.  
  73. 4. JZDOSFLG     Return the vector of the "in dos" flag.
  74.  
  75.         This function returns the address of the "in dos" flag. This
  76.         is valuable in resident programs to determine whether or not
  77.         dos commands can be run when a program is interupted. Normally,
  78.         if the in dos flag <> 0 then a dos call is in progress and dos
  79.         i/o may NOT be performed.
  80.  
  81.         jzdosflg(&wvector);
  82.  
  83.         TVECTOR wvector         This struct is defined in JAZ.H and contains
  84.                                 an segment and offset field. This can be
  85.                                 converted to a far pointer and used to reference
  86.                                 the in dos flag.
  87.  
  88.         EX.
  89.  
  90.           #include <jaz.h>
  91.           TVECTOR wvector;
  92.  
  93.           jzdosflg(&wvector);
  94.  
  95.           if (memb(wvector.segment,wvector.offset))
  96.             printf("\nIn the middle of a dos function call.");
  97.  
  98. 5. JZDOSVER     Return the dos major and minor version.
  99.  
  100.         This function returns an integer equal to the dos version.
  101.         The Low byte will be the major version and the High byte will
  102.         be the minor version.
  103.  
  104.         wversion = jzdosver();
  105.  
  106.         int wversion            The version of dos you are running.
  107.                                 i.e. 0A03 (hex) for dos 3.1
  108.  
  109.         EX.
  110.  
  111.           int wversion;
  112.  
  113.           wversion = jzdosver();                /* get dos version */
  114.  
  115.           /**
  116.            ** exit this mythical program
  117.            ** if the dos version is below 2.0
  118.            **/
  119.  
  120.           if ((wversion & 0xFF) < 2) {
  121.             printf("\nMust have 2.0 or greater to run this program.");
  122.             exit(1);
  123.           }
  124.  
  125. 6. JZDSKFRE     Return the free space remaining on the disk.
  126.  
  127.         This function returns file allocation table information regarding
  128.         free space remaining on the specified disk.
  129.  
  130.         jzdskfre(&wfat,wdrive);
  131.  
  132.         TFAT wfat               This structure is defined in JAZ.H. It
  133.                                 contains fields for free, total, and
  134.                                 used.
  135.  
  136.         int wdrive;             This should be:
  137.                                 0 : default drive
  138.                                 1 : A:
  139.                                 2 : B:
  140.                                 3 : C:
  141.                                 etc.
  142.  
  143.         EX.
  144.  
  145.           #include <jaz.h>
  146.  
  147.           TFAT wfat;
  148.  
  149.           jzdskfre(&wfat,0);    /* get free space on default drive */
  150.  
  151.           if (wfat.free < 360000L)
  152.             printf("\nThis disk is not empty!");
  153.  
  154. 7. JZDSKSTS     Return a disk status code
  155.  
  156.         Return a disk status code for the specified drive. This
  157.         will not cause an "Abort , Retry, Ignore" error and is
  158.         good for determining whether or not a disk is formatted
  159.         or the drive door is open.
  160.  
  161.         wstatus = jzdsksts(wdrive);
  162.  
  163.         int wstatus             $80  -   Timeout
  164.                                 $40  -   Bad Seek
  165.                                 $20  -   Nec Controller failed
  166.                                 $10  -   Bad Crc
  167.                                  $8  -   Attempt to cross 64k boundry
  168.                                  $4  -   Sector not found
  169.                                  $3  -   write protect
  170.                                  $2  -   address mark not found
  171.                                  $1  -   bad command
  172.                                  $0  -   Succsessful
  173.  
  174.         int wdrive              0..3 for floppy diskette drives A,B,C,D
  175.                                 $80..$83 for fixed disk drives  C,D,E,F ETC.
  176.  
  177.  
  178. 8. JZFAT        Get file allocation table information.
  179.  
  180.         Returns Sect/Allocation unit , total Clusters, bytes/sectors
  181.         for the specified drive.
  182.  
  183.         wid = jzfat(wdrive,§_alloc,§_size,&cluster);
  184.  
  185.         char far *wid   Far pointer to FAT id byte
  186.  
  187.         int wdrive      0 : Default drive
  188.                         1 : Drive A
  189.                         2 : Drive B
  190.                         3 : Drive C
  191.                             etc
  192.  
  193.         unsigned
  194.         int sect_alloc  Sectors per allocation unit. (Sect/Cluster)
  195.  
  196.         unsigned
  197.         int sect_size   Bytes per sector
  198.  
  199.         unsigned
  200.         int clusters    Total Clusters on disk
  201.  
  202. 9. JZFNDFST     Find first matching file
  203.  
  204.         This function finds the first matching file given a file
  205.         specification i.e. *.c
  206.  
  207.         werror = jzfndfst(wmask,wattr,&wdta);
  208.  
  209.         int werror      returns 0 if a match was found, otherwise there
  210.                         are no files matching the mask specification.
  211.  
  212.         char *wmask     File specification i.e. "*.DOC"
  213.  
  214.         int wattr       Attribute to search for.
  215.                         1 : Read Only
  216.                         2 : Hidden
  217.                         4 : System
  218.                         8 : Volume Label
  219.                        16 : Sub-Directory
  220.                        32 : Archive
  221.                        These may be "OR"ed together to get combinations.
  222.                        Use 0 for normal files, 0xFF for ALL files
  223.  
  224.         TDIR wdta;     Structure defined in jzdirect.h which defines the
  225.                        disk transfer address buffer, with various directory
  226.                        fields.
  227.  
  228. 10. JZFNDNXT    Find next matching file
  229.  
  230.         Find the next matching file after initially calling jzfndfst.
  231.  
  232.         werror = jzfndnxt(&wdta);
  233.  
  234.         int werror      returns 0 if a match was found, otherwise ther
  235.                         are no more files matching the mask specification.
  236.  
  237.         TDIR wdta       Structure defined in jzdirect.h which defines the
  238.                         disk transfer address buffer, with various directory
  239.                         fields.
  240.  
  241.  
  242.         EX.
  243.           #include <jzdirect.h>
  244.  
  245.           int werror;           /* return error code */
  246.           TDIR wdta;            /* disk directory buffer */
  247.  
  248.           werror = jzfndfst("*.*",0,&wdta);   /* list all files in directory */
  249.  
  250.           while (werror == 0) {
  251.             printf("\n%s",wdir.name);
  252.             werror = jzfndnxt(&wdta);
  253.           }
  254.  
  255. 11. JZGETATR    Get a files attribute
  256.  
  257.         Return the attribute for a given file.
  258.  
  259.         wattr = jzgetatr(wfilename);
  260.  
  261.         int wattr       Attribute returned for file
  262.                        -1 : Error (Probably file not found)
  263.                         1 : Read Only
  264.                         2 : Hidden
  265.                         4 : System
  266.                         8 : Volume Label
  267.                        16 : Sub-Directory
  268.                        32 : Archive
  269.  
  270.         char
  271.         *wfilename      File name to return attribute for
  272.  
  273. 12. JZGETDAT    Return the system date
  274.  
  275.         Return the system date as a string. i.e. 01-25-1986
  276.         Make sure to reserve enough space for the entire date.
  277.         at least 11 chars (including the null terminator)
  278.  
  279.         jzgetdat(wdate);
  280.  
  281.         char *wdate     : date string returned here
  282.  
  283. 13. JZGETDR     Return the current working directory.
  284.  
  285.         Return the working sub-directory as a string.The string will
  286.         not have a "\" char after it so if you want to use this for
  287.         searches, you must concatenate a "\" to it, especially if you
  288.         are in the root dir as it may return "".
  289.  
  290.         jzgetdr(wdir);
  291.  
  292.         char *wdir      Current working sub-directory string on return
  293.  
  294. 14. JZGETDRV    Get logged drive
  295.  
  296.         Return the current logged drive.
  297.  
  298.         wdrive = jzgetdrv();
  299.  
  300.         int wdrive      0 : Drive A
  301.                         1 : Drive B
  302.                         2 : Drive C
  303.                         etc..
  304.  
  305. 15. JZGETDTA    Get the disk transfer address
  306.  
  307.         Return the current disk transfer address from Dos. This is needed
  308.         by the directory routines which change the DTA. They save the address
  309.         in a work variable , then change it for the directory call, then
  310.         restore it. This is necessary 'cuz some of the high level file
  311.         access routines use the DTA as the file buffer!
  312.  
  313.         jzgetdta(wofs,wseg);
  314.  
  315.         int wofs        Offset of DTA address
  316.  
  317.         int wseg        segment of DTA address
  318.  
  319. 16. JZGETFCB    Get an unopened FCB
  320.  
  321.         Return an unopened FCB record given a drive and file name.
  322.         The unopened FCB contains detailed info on the file including
  323.         the starting cluster number. See JZCHKDSK for info on where
  324.         to use this routine.
  325.  
  326.         werror = jzgetfcb(&wfcb,wfilename,wdrive);
  327.  
  328.         int werror      -1 if an error occurred,
  329.                          0 if everything went according to plan.
  330.  
  331.         TFCB wfcb       File control block record defined in JAZ.H
  332.  
  333.         char
  334.         *wfilename      File name to get FCB for. Paths are NOT allowed!
  335.  
  336.         int wdrive      1 : Drive A
  337.                         2 : Drive B
  338.                         3 : Drive C
  339.                         etc...
  340.  
  341.  
  342. 17. JZGETINT    Get an interrupt vector
  343.  
  344.         Return the segment/offset address of a given interrupt number
  345.  
  346.         jzgetint(wint,&wvec);
  347.  
  348.         int wint        Interrupt number to get address of
  349.  
  350.         TVEC wvec       Segment offset record defined in JAZ.H
  351.  
  352. 18. JZGETMEM    Allocate memory
  353.  
  354.         Return a segment pointer to a block of free memory.
  355.  
  356.         werror = jzgetmem(wbytes,&wpointer);
  357.  
  358.         int werror      -1 if an error occurred,
  359.                          0 if everything went according to plan.
  360.  
  361.         unsigned
  362.         int wbytes      Number of bytes requested to allocate
  363.  
  364.         unsigned
  365.         int wpointer    Pointer to segment of free memory.
  366.  
  367. 19. JZGETTIM    Get the system time
  368.  
  369.         Return the system time as a string: 19:05:22 . Make sure to
  370.         allocate at least 9 chars for the string length.
  371.  
  372.         jzgettim(wtime);
  373.  
  374.         char *wtime     Time string to be returned.
  375.  
  376. 20. JZGETVOL    Get the volume label of a drive
  377.  
  378.         Get the volume label for the specified drive;
  379.  
  380.         wptr = jzgetvol(wdrive,wvolume);
  381.  
  382.         char *wptr      Pointer to wvolume argument for using in
  383.                         expressions. Null pointer if error occured.
  384.  
  385.         wdrive          0 : Drive A
  386.                         1 : Drive B
  387.                         2 : Drive C
  388.                         etc.
  389.  
  390.         char
  391.         *wvolume        String for volume label. Make sure to allocate
  392.                         at least 13 chars for this string.
  393.  
  394. 21. JZLOGDRV    Change the logged drive.
  395.  
  396.         Set the current logged drive.
  397.  
  398.         wnumdrives = jzlogdrv(wdrive);
  399.  
  400.         int
  401.         wnumdrives      Returns the number of drives in the system
  402.  
  403.         int wdrive      0 : Drive A
  404.                         1 : Drive B
  405.                         2 : Drive C
  406.                         etc
  407.  
  408. 22. JZOPNFIL    Open a file handle
  409.  
  410.         Open a file handle for read/write access
  411.  
  412.         werror = jzopnfil(wname,wmode);
  413.  
  414.         int werror      -1 if an error occurred,
  415.                          otherwise a valid dos file handle
  416.  
  417.         char *wname     File name to open
  418.  
  419.         int wmode       0 : read only
  420.                         1 : write only
  421.                         2 : read/write
  422.                         et. al.
  423.  
  424. 23. JZPOPDIR    Pop a directory
  425.  
  426.         Pop a directory from the directory stack and change the
  427.         current logged directory to it.
  428.  
  429.         jzpopdir(&whead,wpopdrive);
  430.  
  431.         TSTKHEAD
  432.         whead           Head of stack structure defined in JAZ.H
  433.  
  434.         int wpopdrive   1 : Pop the drive as well as the directory
  435.                         0 : Don't pop the drive, Only the directory.
  436.  
  437. 24. JZPSHDIR    Push a directory
  438.  
  439.         Push a directory and drive onto the directory stack for subsequent
  440.         use by jzpopdir.
  441.  
  442.         jzpshdir(&whead);
  443.  
  444.         TSTKHEAD
  445.         whead           Head of stack structure defined in JAZ.H
  446.  
  447. 25. JZREDFIL    Read from a file handle.
  448.  
  449.         Read data from a file handle into a buffer. This is a fairly
  450.         high speed disk access method, very useful for copying files and
  451.         such.
  452.  
  453.         wnum = jzredfil(whandle,wbuf,wamt);
  454.  
  455.         unsigned
  456.         int wnum        Actual number of bytes read from the file. A value
  457.                         of < wamt (or 0) means end of file.
  458.  
  459.         int whandle     The handle of the previously opened file from a call
  460.                         to jzopnfil/jzcrtfil
  461.  
  462.         char *wbuf      Buffer to read the data into. Usually an array or
  463.                         pointer to char.
  464.  
  465.         unsigned
  466.         int wamt        The number of bytes requested to read.
  467.  
  468. 26. JZSEKFIL    Seek into a file.
  469.  
  470.         Seek to a position into a file. (Random Access). There are 3
  471.         methods of seeking:
  472.         0 : Seek relative to beginning of file.
  473.         1 : Seek relative to Current file position
  474.         2 : Seek relative to End of File
  475.  
  476.         Note that negative offsets are not allowed !.
  477.  
  478.         wpos = jzsekfil(whandle,woffset,wmethod);
  479.  
  480.         long wpos       Position of the file pointer in bytes relative
  481.                         to the beginning of the file.
  482.  
  483.         int whandle     The handle of the previously opened file from a call
  484.                         to jzopnfil/jzcrtfil
  485.  
  486.         unsigned int
  487.         woffset         Offset of bytes to seek from one of the
  488.                         methods specified in wmethod.
  489.  
  490.         int wmethod     0 : Seek relative to beginning of file.
  491.                         1 : Seek relative to Current file position
  492.                         2 : Seek relative to End of File
  493.  
  494.  
  495.         EX.
  496.  
  497.           /* how to seek to the end of the file minus one */
  498.           /* difficult 'cuz negative offsets not allowed  */
  499.  
  500.           int whandle;
  501.           long fsize,jzsekfil();
  502.  
  503.           . . . . .
  504.  
  505.           /* assume file was already opened at this point */
  506.  
  507.           fsize = jzsekfil(whandle,0L,2);           /* seek to end of file */
  508.           if (fsize) {
  509.             fsize --;                               /* subtract 1 from size */
  510.             jzsekfil(whandle,fsize,0);              /* seek to eof - 1 */
  511.           }
  512.  
  513. 27. JZSETATR    Set a files attributes
  514.  
  515.         Set the attributes of a given file .
  516.  
  517.         werror = jzsetatr(wname,wattr);
  518.  
  519.         int werror      -1 if an error occurred,
  520.                          0 if everything went according to plan.
  521.  
  522.         char *wname     File name with which to set attributes
  523.  
  524.         int wattr       Attribute used to set for file. These may
  525.                         be *or* ed together.
  526.                          1 : Read Only
  527.                          2 : Hidden
  528.                          4 : System
  529.                          8 : Volume Label
  530.                         16 : Sub-Directory
  531.                         32 : Archive
  532.  
  533. 28. JZSETDTA    Set the disk transfer address
  534.  
  535.         This function sets the disk transfer address to the given
  536.         buffer (relative to DS). Used internally for jzfndfst &
  537.         jzfndnxt.
  538.  
  539.         jzsetdta(&wdta);
  540.  
  541.         TDTA wdta       Disk transfer structure to point DTA to.
  542.  
  543. 29. JZSETINT    Set an interrupt vector
  544.  
  545.         Set the vector for a particular interrupt of your specification.
  546.         Useful for redirecting interrupts to your routines.
  547.  
  548.         jzsetint(wint,wvec);
  549.  
  550.         int wint        Interrupt vector number to set.
  551.  
  552.         TVECTOR wvec    Structure where segment and offset fields
  553.                         are already filled in.
  554.  
  555.         EX.
  556.  
  557.         TVECTOR wvec;
  558.         int prtsc();
  559.  
  560.         wvec.segment = getcs();
  561.         wvec.offset = prtsc;            /* get address of new print screen */
  562.  
  563.         jzsetint(5,wvec);
  564.  
  565. 30. JZTRMRES    Terminate and stay resident
  566.  
  567.         Terminate the current process but leaving the program resident
  568.         in memory.
  569.  
  570.         jztrmres();
  571.  
  572. 31. JZUNQFIL    Return a unique file handle/name.
  573.  
  574.         This routine is functionally equivalent to JZOPNFIL
  575.         except it returns a handle pointing to a file name
  576.         that does not already exist. Very useful for temp
  577.         files.
  578.  
  579.         whandle = jzunqfil(wpath,wattr);
  580.  
  581.         int whandle     -1 if an error occurred,
  582.                          otherwise a valid dos file handle.
  583.  
  584.         char *wpath     String containing the path to put the
  585.                         unique file. This must end in a "\" and
  586.                         must be a variable as the file name will
  587.                         be placed in this variable.
  588.  
  589.         int wattr       Attribute used to
  590.                         create the unique file name
  591.                          1 : Read Only
  592.                          2 : Hidden
  593.                          4 : System
  594.                          8 : Volume Label
  595.                         16 : Sub-Directory
  596.                         32 : Archive
  597.  
  598. 32. JZWRTFIL    Write data to a file handle.
  599.  
  600.         Write data from a buffer to a file handle. Like jzredfil, this
  601.         routine is useful for high speed data transfer.
  602.  
  603.         wnum = jzwrtfil(whandle,wbuf,wamt);
  604.  
  605.         unsigned
  606.         int wnum        Actual number of bytes written to the file.
  607.  
  608.         int whandle     The handle of the previously opened file from a call
  609.                         to jzopnfil/jzcrtfil
  610.  
  611.         char *wbuf      Buffer to write the data from. Usually an array or
  612.                         pointer to char.
  613.  
  614.         unsigned
  615.         int wamt        The number of bytes requested to write.
  616.  
  617.  
  618. 33. TRUNCATE    Truncate a file.
  619.  
  620.         Truncate a file to a certain size.
  621.  
  622.         werror = truncate(wname,wsize);
  623.  
  624.         int werror      -1 if an error occurred,
  625.                          0 if everything went according to plan.
  626.  
  627.         char *wname     File name to truncate
  628.  
  629.         long wsize      New Size of the file.
  630.  
  631.  
  632.                         STRING HANDLING
  633.  
  634. 1.  INDEX       Return the index of a character in a string.
  635.  
  636.         Return the index position of the occurance of a character
  637.         in a substring or -1 if the character was not found.
  638.  
  639.         wpos = index(wsource,wch);
  640.  
  641.         int wpos        index of occurance of character wch in the string
  642.                         wsource. Returns -1 if no occurance.
  643.  
  644.         char *wsource   Pointer to the source string to search.
  645.  
  646.         int wch         Character to do the search for.
  647.  
  648. 2.  JZCHRPOS    Return the index of a character in a string.
  649.  
  650.         Return the index position of the occurance of a character
  651.         in a substring or -1 if the character was not found.
  652.  
  653.         wpos = jzchrpos(wsource,wch);
  654.  
  655.         int wpos        index of occurance of character wch in the string
  656.                         wsource. Returns -1 if no occurance.
  657.  
  658.         char *wsource   Pointer to the source string to search.
  659.  
  660.         int wch         Character to do the search for.
  661.  
  662. 3.  JZCHRSTR    Concatenate a character onto a string
  663.  
  664.         This function performs the task of appending a single char
  665.         to a string (which strcat will not do). It appends a null
  666.         terminating character to the end of the source string to
  667.         maintain string compatibility.
  668.  
  669.         jzchrstr(wsource,wch);
  670.  
  671.         char *wsource   Source string to concatenate character to
  672.  
  673.         int wch         Character to concatenate to wsource.
  674.  
  675. 4.  JZCNTSTR    Return a centered string.
  676.  
  677.         This function returns a string padded with blanks to be
  678.         centered in a give field width. Note that the maximum limit
  679.         on string size for this routine is 255. The routine itself
  680.         does NO range checking so it is up to the application itself
  681.         to insure that this does not happen. This routine uses a static
  682.         buffer for the pointer to return so subsequent calls to the routine
  683.         destroy the previous contents of the returned pointer!
  684.  
  685.         wptr = jzcntstr(wsource,wnum);
  686.  
  687.         char *wptr      pointer to centered string.
  688.  
  689.         char *wsource   String to have centered.
  690.  
  691.         wnum            Width of field to center on.
  692.  
  693. 5.  JZDLTSTR    Delete a substring from another string.
  694.  
  695.         Give a starting and ending position, this routine will remove
  696.         a portion of a string.
  697.  
  698.         wnum = jzdltstr(wsource,wfrom,fto);
  699.  
  700.         int wnum        Number of chars actually deleted.
  701.  
  702.         char *wsource   String to delete chars from.
  703.  
  704.         int wfrom       Starting index to delete from
  705.  
  706.         int wto         Ending index to delete to
  707.  
  708. 6.  JZGETPCE    Get delimited piece of substring
  709.  
  710.         This routine returns the "n"th piece of a delimited string.
  711.         i.e. Jaz;10318 Broom Lane;Seabrook;Md;20706
  712.         the 3rd ";" piece of the string is "Seabrook"
  713.  
  714.         wptr = jzgetpce(wsource,wdestin,wdel,wnum);
  715.  
  716.         char *wptr      Pointer to wdestin, the destination piece.
  717.  
  718.         char *wsource   The source string with delimiters
  719.  
  720.         char *wdestin   The destination string.
  721.  
  722.         int wdel        The character used as a delimiter
  723.  
  724.         int wnum        Which piece do you want?
  725.  
  726. 7.  JZINSSTR    Insert a string into another string.
  727.  
  728.         This routine does a string insert of one string into another at
  729.         a given starting position. Note that if wstart is > than the
  730.         length of the source string, blanks will be appended.
  731.  
  732.         jzinsstr(wdestin,wsource,wstart);
  733.  
  734.         char *wdestin   Pointer to destination string (to be inserted).
  735.  
  736.         char *wsource   Pointer to string to insert
  737.  
  738.         int wstart      Index of position to start inserting.
  739.  
  740. 8.  JZLFTSTR    Return the left n chars from a string
  741.  
  742.         This routine returns the left n chars of a given string.
  743.         note that this routine uses a static 255 byte buffer for the pointer to
  744.         return so subsequent calls to the routine destroy the
  745.         previous contents of the returned pointer!
  746.  
  747.         wptr = jzlftstr(wstr,wnum);
  748.  
  749.         char *wptr      Pointer to static buffer containing the left string.
  750.  
  751.         char *wstr      Source string
  752.  
  753.         int wnum        The number of chars you want from the source string.
  754.  
  755. 9.  JZMIDSTR    Return the middle n chars from a string.
  756.  
  757.         Given a starting position and a length, return the mid chars from
  758.         a given string.
  759.         note that this routine uses a static 255 byte buffer for the pointer to
  760.         return so subsequent calls to the routine destroy the
  761.         previous contents of the returned pointer!
  762.  
  763.         wptr = jzmidstr(wstr,wstart,wlen);
  764.  
  765.         char *wptr      pointer to static buffer containing the sub string
  766.  
  767.         char *wstr      Source string
  768.  
  769.         int wstart      Starting index of sub string
  770.  
  771.         int wlen        Length of substring.
  772.  
  773. 10. JZPAD       Pad a string
  774.  
  775.         This routine pads a given string with a given char.
  776.         Note that this routine uses a static 255 byte buffer for the pointer to
  777.         return so subsequent calls to the routine destroy the
  778.         previous contents of the returned pointer!
  779.  
  780.         wptr = jzpad(wstr,wch);
  781.  
  782.         char *wptr      Pointer to static buffer containing padded string.
  783.  
  784.         char *wstr      Source string to pad.
  785.  
  786.         int wch         Character to pad with.
  787.  
  788. 11. JZPRSFIL    Parse a path\file
  789.  
  790.         This routine parses a path name into a seperate file name and
  791.         path name with the path name ending in a "\".
  792.  
  793.         jzprsfil(wfull,wpath,wfile);
  794.  
  795.         char *wfull     Full path. i.e. "\\MSC\\JAZ\\JZSEARCH.EXE"
  796.  
  797.         char *wpath     Returned Path portion of wfull
  798.  
  799.         char *wfile     Returned file name portion of wfull
  800.  
  801. 12. JZRGTJST    Right justify a string
  802.  
  803.         This routine right justifies a given string. Effectively padding to
  804.         the right.
  805.         Note that this routine uses a static 255 byte buffer for the pointer to
  806.         return so subsequent calls to the routine destroy the
  807.         previous contents of the returned pointer!
  808.  
  809.         wptr = jzrgtjst(wstr,wnum);
  810.  
  811.         char *wptr      Pointer to static buffer containing padded string.
  812.  
  813.         char *wstr      Source string to pad.
  814.  
  815.         int wch         Character to pad with.
  816.  
  817. 13. JZRGTSTR    Return the right n chars of a string
  818.  
  819.         This routine returns the rightmost n chars of a given string.
  820.         Note that this routine uses a static 255 byte buffer for the pointer to
  821.         return so subsequent calls to the routine destroy the
  822.         previous contents of the returned pointer!
  823.  
  824.         wptr = jzrgtstr(wstr,wnum);
  825.  
  826.         char *wptr      Pointer to static buffer containing the left string.
  827.  
  828.         char *wstr      Source string
  829.  
  830.         int wnum        The number of chars you want from the source string.
  831.  
  832. 14. JZRPLSTR    Replace chars in a string.
  833.  
  834.         This routine replaces characters in a string with a given substring.
  835.  
  836.         jzrplstr(wdestin,wsource,wstart,wlen);
  837.  
  838.         char *wdestin   Destination string to insert into.
  839.  
  840.         char *wsource   Source string to insert.
  841.  
  842.         int wstart      Starting index to replace.
  843.  
  844.         int wlen        Length of chars to insert.
  845.  
  846. 15. JZSTRCAT    Concatenate multiple strings
  847.  
  848.         This routine concatenates multiple strings together in one shot.
  849.  
  850.         jzstrcat(wsource,wstr1,wstr2,NULL);
  851.  
  852.         char *wsource   String to concatenate onto
  853.  
  854.         char *wstr1     Strings to concatenate
  855.              *wstr2
  856.              etc...
  857.  
  858.         char NULL       The Routine stops when it detects a null string.
  859.                         You may use 0 here but it's less portable.
  860.  
  861. 16. JZSTRPOS    Return a pointer to a substring
  862.  
  863.         Returns a pointer to a substring within another string or null
  864.         if not found.
  865.  
  866.         wptr = jzstrpos(wobject,wtarget);
  867.  
  868.         char *wptr      Pointer to occurance of wobject in wtarget or null
  869.                         if not found.
  870.  
  871.         char *wobject   String we are searching for
  872.  
  873.         char *wtarget   String we are searching.
  874.  
  875. 17. JZWLDCRD    Wild card file search
  876.  
  877.         This routine implements a very simplistic wild card match on
  878.         two strings.
  879.  
  880.         wmatch = jzwldcrd(wsource,wwild);
  881.  
  882.         int wmatch      1 : if match
  883.                         0 : if no match
  884.  
  885.         char *wsource   Source string we are checking
  886.  
  887.         char *wwild     Wild card string
  888.  
  889. 18. LITERAL     Parse a user string
  890.  
  891.         Convert a user string with escape sequences to an internal string.
  892.          /**/ delineate comments
  893.          \x1b translates to char(0x1b)
  894.          \27  translates to char(27)
  895.          \"   translates to "
  896.          \'   translates to '
  897.          \\   translates to \
  898.  
  899.          literal(wsource,wdestin);
  900.  
  901.          char *wsource  Original string with esc sequences
  902.  
  903.          char *wdestin  Destination string with expansions.
  904.  
  905. 19. RINDEX      Return the rear index of a char in a string.
  906.  
  907.         Return the last occurance of a char within a string or
  908.         -1 if not found.
  909.  
  910.         wpos = rindex(wsource,wch);
  911.  
  912.         int wpos        index position of occurance of last wch in wsource
  913.                         or -1 if wch was not found.
  914.  
  915.         char *wsource   String to do the search on
  916.  
  917.         int wch         Char we are searching for.
  918.  
  919. 20. TABTOSP     Convert tabs to spaces
  920.  
  921.         Expand tab chars in a string to spaces given that the default tabs
  922.         are 1,9,17,25,33,41 etc.
  923.  
  924.         wptr = tabtosp(wsource,wdestin);
  925.  
  926.         char *wptr      Returned Pointer to wdestin.
  927.  
  928.         char *wsource   Source string with tabs in it.
  929.  
  930.         char *wdestin   Destination string without tabs.
  931.  
  932.  
  933.  
  934.                 LOW LEVEL OPERATING SYSTEM ROUTINES
  935.  
  936.  
  937. 1.  CLI         Clear interrupts
  938.  
  939.         Clear the interrupt flag disabling interrupts
  940.  
  941.         cls();
  942.  
  943. 2.  DISKINFO    Get low level disk info
  944.         This routine gets low level disk info directly from the
  945.         boot sector. This will NOT work on a ram disk. It will
  946.         work only on MSDOS diskettes version 2.0 and above may not
  947.         work on some variations of MSDOS.
  948.  
  949.         werror = diskinfo(&wdiskblk,wdrive);
  950.  
  951.         int werror      Dos disk error code. Anything <> 0 means some
  952.                         kind of error occured.
  953.  
  954.         TDISKBLK
  955.         wdiskblk        Disk block structure defined in JAZ.H . This record
  956.                         contains fields for many low level disk paramters.
  957.  
  958.         int wdrive      0 : Drive A
  959.                         1 : Drive B
  960.                         2 : Drive C
  961.                         etc.
  962.  
  963. 3.  DOSREADS    Read disk sectors
  964.  
  965.         Directly read sectors from the disk. This routine bypasses the
  966.         Abort, Retry, Ignore message that you usually get from dos so
  967.         you can use it as a disk status check.
  968.  
  969.         werror = dosreads(wdrive,wsector,wamt,wbuf);
  970.  
  971.         int werror      Dos error code for read. It will be 0 if no error
  972.                         occurred, otherwise a dos error code.
  973.  
  974.         int wdrive      0 : Drive A
  975.                         1 : Drive B
  976.                         2 : Drive C
  977.                         etc.
  978.  
  979.         int wsector     Starting sector number.
  980.  
  981.         int wamt        Number of sectors to read
  982.  
  983.         char *wbuf      Buffer to read data into.
  984.  
  985. 4.  DOSWRITS    Write Disk Sectors
  986.  
  987.         Directly write sectors to the disk. This routine bypasses the
  988.         Abort, Retry, Ignore message that you usually get from dos so
  989.         you can use it as a disk status check.
  990.  
  991.         werror = doswrits(wdrive,wsector,wamt,wbuf);
  992.  
  993.         int werror      Dos error code for write. It will be 0 if no error
  994.                         occurred, otherwise a dos error code.
  995.  
  996.         int wdrive      0 : Drive A
  997.                         1 : Drive B
  998.                         2 : Drive C
  999.                         etc.
  1000.  
  1001.         int wsector     Starting sector number.
  1002.  
  1003.         int wamt        Number of sectors to write
  1004.  
  1005.         char *wbuf      Buffer to write data from
  1006.  
  1007. 5.  GETCS       Get the code segment value
  1008.  
  1009.         Return the segment value for the code segment.
  1010.  
  1011.         wcode = getcs();
  1012.  
  1013.         int wcode       Value to be returned for the code segment
  1014.  
  1015. 6.  GETDS       Get the data segment value
  1016.  
  1017.         Return the segment value for the data segment.
  1018.  
  1019.         wcode = getds();
  1020.  
  1021.         int wcode       Value to be returned for the data segment
  1022.  
  1023. 7.  GETES       Get the extra segment value
  1024.  
  1025.         Return the segment value for the extra segment.
  1026.  
  1027.         wcode = getes();
  1028.  
  1029.         int wcode       Value to be returned for the extra segment
  1030.  
  1031. 8.  GETSS       Get the stack segment value
  1032.  
  1033.         Return the segment value for the stack segment.
  1034.  
  1035.         wcode = getss();
  1036.  
  1037.         int wcode       Value to be returned for the extra segment
  1038.  
  1039. 9.  INSINT24    Install a critical error handler
  1040.  
  1041.         This routine installs the critical error handler in place
  1042.         of the normal one, eliminating those pesky abort, retry, ignore
  1043.         messages.
  1044.         Note that you must call int24err() after every i/o call or you
  1045.         run the risk of hanging your system on a critical error.
  1046.  
  1047.         insint24();
  1048.  
  1049. 10. INT24ERR    Return an int 24 error code
  1050.  
  1051.         This routine fetches the error code (if any) after an i/o call
  1052.         after. The insint24 routine must have been previously called.
  1053.  
  1054.         werror = int24err();
  1055.  
  1056.         int werror      0 if No i/o error otherwise a dos error code.
  1057.                         Check the Dos Ref Manual for a description of
  1058.                         error codes and thier meanings.
  1059.  
  1060. 11. INT24HND    Critical error dispatcher
  1061.  
  1062.         This is the internal low level critical error dispatcher.
  1063.         The file name is INT24HND.ASM
  1064.  
  1065. 12. INTR        Interrupt Gate
  1066.  
  1067.         This routine provides a way to make bios and dos calls in a similar
  1068.         fashion to Turbo Pascal (Tm). See also MSDOS (under MISC MACROS).
  1069.  
  1070.         intr(&wreg);
  1071.  
  1072.         TREG wreg       Register structure for passing to dos or bios.
  1073.  
  1074. 13. JZBIGFAT    Determine FAT SIZE
  1075.  
  1076.         Return 1 if FAT is 16 bit, otherwise, return 0
  1077.         See JZCHKDSK.DMO for ideas on this one
  1078.  
  1079.         wbig = jzbigfat(wtotalsect,wsectsize);
  1080.  
  1081.         int wbig        Returns
  1082.                         1 : 16 bit fat
  1083.                         0 : 12 bit fat
  1084.  
  1085.         int
  1086.         wtotalsect      : This must be the total sectors on disk.
  1087.  
  1088.         int
  1089.         wsectsize       : This must be the amount of bytes/sector on disk.
  1090.  
  1091. 14. JZFATEOF    Determine if at end of cluster chain for file
  1092.  
  1093.         Return true if at the end of a files cluster chain.
  1094.         See JZCHKDSK.DMO for ideas on this one
  1095.  
  1096.         weof = jzfateof(wcluster,wbig);
  1097.  
  1098.         int weof        Returns:
  1099.                         1 : End of file cluster chain
  1100.                         0 : More to go.
  1101.  
  1102.         unsigned int
  1103.         wcluster        Cluster number we are currently looking at
  1104.  
  1105.         int wbig        1 : 16 bit fat
  1106.                         0 : 12 bit fat
  1107.  
  1108. 15. JZGETCLS    Convert Fat index to Cluster number
  1109.  
  1110.         Given a FAT array, return the cluster number for a particular index.
  1111.         See JZCHKDSK.DMO for ideas on this one
  1112.  
  1113.         wcluster = jzgetcls(wfat,wcluster,wbig);
  1114.  
  1115.         int wcluster    Returned cluster number
  1116.  
  1117.         char *wfat      Buffer of file allocation stuff
  1118.  
  1119.         int wcluster    Current cluster number
  1120.  
  1121.         int wbig        1 : 16 bit fat
  1122.                         0 : 12 bit fat
  1123.  
  1124. 16. JZGETDIR    Get a pointer to the disk directories
  1125.  
  1126.         Return pointer to disk directories and the number of root
  1127.         directory entires.
  1128.  
  1129.         jzgetdir(&wdir,wdrive,&wnum);
  1130.  
  1131.         TDIR *wdir      Pointer to low level directory information.
  1132.                         Note that we must supply the routine a pointer
  1133.                         to a pointer.
  1134.  
  1135.         int wdrive      0 : Drive A
  1136.                         1 : Drive B
  1137.                         2 : Drive C
  1138.  
  1139.         int wnum        Returned Number of root directory entries.
  1140.  
  1141. 17. JZGETFAT    Get a pointer to the FAT
  1142.  
  1143.         Return a pointer to the file allocation for the specified
  1144.         disk drive.
  1145.  
  1146.         jzgetfat(&wfat,wdrive);
  1147.  
  1148.         char *wfat      Returned pointer to a file allocation table. Note
  1149.                         that this argument is a pointer to a pointer.
  1150.  
  1151.         int wdrive      0 : Drive A
  1152.                         1 : Drive B
  1153.                         2 : Drive C
  1154.  
  1155. 18. JZINSINT    Install a generic interrupt handler
  1156.  
  1157.         This routine installs an interrupt into the generic interrupt
  1158.         handler routine: JZINTHND.
  1159.  
  1160.         jzinsint(wint,wfunction);
  1161.  
  1162.         int wint        Interrupt number to define/redefine
  1163.  
  1164.         int
  1165.         wfunction()     Address of function to call when this interrupt
  1166.                         vector is invoked.
  1167.  
  1168.         EX.
  1169.  
  1170.           #include <jaz.h>
  1171.           #include <jzscreen.h>
  1172.  
  1173.           int clock();
  1174.           int gcount = 17;                        /* clock tic counter */
  1175.  
  1176.           #define TIMER 0x1C
  1177.  
  1178.           main()
  1179.           {
  1180.  
  1181.             jzinsint(TIMER,clock);         /* install the new timer interrupt */
  1182.  
  1183.             jztrmres();                   /* terminate but stay resident */
  1184.  
  1185.           }
  1186.  
  1187.           clock()
  1188.           {
  1189.              char wstr[9];
  1190.  
  1191.            /* clock tics 18.2 times a second */
  1192.              if (gcount >= 17) {
  1193.                jzbiostm(wstr);
  1194.                jzscrprn(wstr,0,72,RED);
  1195.                gcount = 0;
  1196.              }
  1197.              else
  1198.                gcount ++;
  1199.           }
  1200.  
  1201.  
  1202. 19. JZINTHND    Generic Interrupt Dispatcher
  1203.  
  1204.         This routine handles the low level pushes, pops, and stack
  1205.         manipulation for a generic interrupt handler.
  1206.         The file name is JZINTHND.ASM
  1207.  
  1208.  
  1209. 20. READSECT    Read sectors from bios
  1210.  
  1211.         This routine uses bios to directly read sectors from the disk.
  1212.         It bypasses dos so you don't get the abort, retry, ignore
  1213.         messages.
  1214.  
  1215.         werror = readsect(wnum,wtrack,wsector,whead,wdrive,wbuf)
  1216.  
  1217.         int werror      0 if no error occurred, otherwise one of the following
  1218.                         error codes:
  1219.                         $80  -   Timeout
  1220.                         $40  -   Bad Seek
  1221.                         $20  -   Nec Controller failed
  1222.                         $10  -   Bad Crc
  1223.                          $8  -   Attempt to cross 64k boundry
  1224.                          $4  -   Sector not found
  1225.                          $3  -   write protect
  1226.                          $2  -   address mark not found
  1227.                          $1  -   bad command
  1228.  
  1229.         int wnum        Number of sectors to read 0..255
  1230.  
  1231.         int wtrack      Starting Track number
  1232.  
  1233.         int wsector     Starting Sector number
  1234.  
  1235.         int whead       Head number
  1236.  
  1237.         int wdrive      Should be set to one of the following:
  1238.                         0..3 for floppy diskette drives A,B,C,D
  1239.                         $80..$83 for fixed disk drives  C,D,E,F ETC.
  1240.  
  1241.         char *wbuf      Buffer to read data into. Make sure it is at least
  1242.                         wnum * wsectorsize bytes long.
  1243.  
  1244. 21. STI         Set the interrupt flag
  1245.  
  1246.         Set the interrupt flag, enabling interrupts.
  1247.  
  1248.         sti();
  1249.  
  1250.                             UTILITY ROUTINES
  1251.  
  1252. 1.  GETCRC      Get a crc code for a buffer
  1253.  
  1254.         This routine returns a Cyclic Redundancy Check code for a given
  1255.         buffer.
  1256.  
  1257.         wcrc = getcrc(wbuf,wlen);
  1258.  
  1259.         unsigned int
  1260.         wcrc            Crc Code returned from function.
  1261.  
  1262.         char *wbuf      Pointer to data buffer to check.
  1263.  
  1264.         int wlen        sizeof (wbuf)
  1265.  
  1266. 2.  JZBEEP      Sound a beep to the console
  1267.  
  1268.         This routine sounds a slightly more pleasant beep to the
  1269.         console then the standard printf("%c",7);
  1270.  
  1271.         jzbeep();
  1272.  
  1273. 3.  JZBIOSTM    Return a "bios" time string.
  1274.  
  1275.         This routine returns a time string using the bios tic
  1276.         count instead of the dos function. This is handy during
  1277.         interrupt handlers where we cannot make dos calls.
  1278.  
  1279.         jzbiostm(wtime);
  1280.  
  1281.         char *wtime     Time string returned in the form HH:MM:SS
  1282.  
  1283. 4.  JZDELAY     Delay program execution
  1284.  
  1285.         Delay the current program for the specified number of clock
  1286.         tics.
  1287.  
  1288.         jzdelay(wtics);
  1289.  
  1290.         long wtics      Number of tics to delay. There are about 18
  1291.                         clock tics in a second. Make sure you use a
  1292.                         long value here or the high word may cause
  1293.                         you to "hang" for a long time. (No Pun Intended)
  1294.  
  1295. 5.  JZINTDIR    Initialize the directory stack.
  1296.  
  1297.         This routine initializes the directory head structure in
  1298.         preperation for a call to jzpshdir.
  1299.  
  1300.         jzintdir(&wdirhead);
  1301.  
  1302.         TDIRHEAD
  1303.         wdirhead        Head of directory structure defined in JAZ.H
  1304.  
  1305.  
  1306. 6.  JZINTSTK    Initialize user stack
  1307.  
  1308.         This routine initializes the user stack in preperation
  1309.         for a call to jzpush
  1310.  
  1311.         jzintstk(&whead);
  1312.  
  1313.         TSTKHEAD
  1314.         whead           Record containing information pertaining
  1315.                         to the user stack
  1316.  
  1317. 7.  JZPOP       Pop data from the user stack
  1318.  
  1319.         This routine allows data from the user stack to be "popped" into
  1320.         a variable. This is useful because data type is not a consideration
  1321.         and therefore variables can be popped to variables of other types.
  1322.  
  1323.         jzpop(&whead,wdata,wsize);
  1324.  
  1325.         TSTKHEAD
  1326.         whead           Record containing information pertaining
  1327.                         to the user stack.
  1328.  
  1329.  
  1330.         char *wdata     This can actually be a pointer to any type
  1331.                         of data. If type checking is enabled, you
  1332.                         may have to use a cast.
  1333.         unsigned int
  1334.         wsize           Set this argument to 0 to receive the default
  1335.                         size, which was specified when jzpush was
  1336.                         called. Setting this value to something other
  1337.                         than 0 will override the default and the number
  1338.                         of bytes specified. Note that this does not pop
  1339.                         other items off the stack, but merely takes more
  1340.                         (or less) contiguous memory and places it in wdata.
  1341.  
  1342.  
  1343. 8.  JZPRNPTR    Print data from any data type
  1344.  
  1345.         This function allows byte by byte printing of a struct useful
  1346.         usually for debugging purposes.
  1347.  
  1348.         jzprnptr(wptr,wctrl,wlength);
  1349.  
  1350.         char *wptr      This can be any type of pointer to a structure,
  1351.                         not just char. You may have to use a cast if
  1352.                         you use strong type checking.
  1353.  
  1354.         char *wctrl     This is the control string for the print.
  1355.                         i.e.
  1356.                         "\n%0004X" or
  1357.                         "%c "      or
  1358.                         "%d "      etc.
  1359.  
  1360.         int wlength     The length of the data object to print. Typically
  1361.                         it would be sizeof(wptr);
  1362.  
  1363. 9.  JZPUSH      Push data onto the user stack
  1364.  
  1365.         This routine is used to push data onto the local stack where
  1366.         it can be popped off later.
  1367.  
  1368.         jzpush(&whead,wdata,wsize);
  1369.  
  1370.         TSTKPTR
  1371.         whead           Record containing information pertaining
  1372.                         to the user stack.
  1373.  
  1374.         char *wdata     This can actually be a pointer to any type
  1375.                         of data. If type checking is enabled, you
  1376.                         may have to use a cast.
  1377.  
  1378.         unsigned int
  1379.         wsize           Set this argument to sizeof(wdata) usually unless
  1380.                         you want more or less bytes to be saved on the stack.
  1381.  
  1382. 10. JZPUTPRN    Put Data to the LPT1 device
  1383.  
  1384.         This routine writes chars to LPT1 using bios. It returns the
  1385.         printer status word.
  1386.  
  1387.         wstatus = jzputprn(wch);
  1388.  
  1389.         int wstatus     Printer status word. See the bios tech ref manual
  1390.                         for details about how to read this word.
  1391.  
  1392.         int wch         Character to write to the printer
  1393.  
  1394. 11. JZREBOOT    Reboot the computer
  1395.  
  1396.         This routine allows you to either perform a warm boot or a
  1397.         cold boot of the machine. The warm boot simulates a Ctrl-Alt-Del,
  1398.         and the cold boot simulates a power on with a memory and
  1399.         diagnostics check.
  1400.  
  1401.         jzreboot(wcode);
  1402.  
  1403.         int wcode       1 : cold boot
  1404.                         0 : warm boot
  1405.  
  1406. 12. JZTIMER     Time an event
  1407.  
  1408.         This routine performs a timing of an event in seconds. This routine
  1409.         uses a static variable to store the bios tic count. Because of this
  1410.         it needs to be called once to initialize the tic count.
  1411.  
  1412.         welapse = jztimer();
  1413.  
  1414.         unsigned int
  1415.         welapse         Returned seconds since the last call to this
  1416.                         routine.
  1417.  
  1418.         EX.
  1419.  
  1420.           main()
  1421.           {
  1422.  
  1423.             unsigned int w;
  1424.  
  1425.             jztimer();          /* initialize the timer */
  1426.  
  1427.             for (w = 0 ; w < 0xFFFF ; w ++)     /* loop for nothin' */
  1428.                 ;
  1429.  
  1430.             printf("Execution of this loop took %d seconds!",jztimer());
  1431.           }
  1432.  
  1433. 13. MEMB        Return a byte of memory
  1434.  
  1435.         This function returns a byte of memory, given a segment,offset
  1436.         pair.
  1437.  
  1438.         wch = memb(wseg,wofs);
  1439.  
  1440.         int wch         Char returned from memory
  1441.  
  1442.         wseg            Segment value to read from
  1443.  
  1444.         wofs            Offset value to read from
  1445.  
  1446.         EX.
  1447.  
  1448.           if (memb(0x40,0x49) == 3)
  1449.             printf("I detect a color card in this computer!");
  1450.  
  1451. 14. MEMW        Return a word of memory
  1452.  
  1453.         This function returns a word of memory, given a segment
  1454.         pair.
  1455.  
  1456.         wch = memw(wseg,wofs);
  1457.  
  1458.         int wch         word returned from memory
  1459.  
  1460.         wseg            Segment value to read from
  1461.  
  1462.         wofs            Offset value to read from
  1463.  
  1464.         EX.
  1465.  
  1466.           wkeystatus = memw(0x40,0x17); /* get keyboard status word */
  1467.  
  1468. 15. MEML        Return a long of memory
  1469.  
  1470.         This function returns a long of memory, given a segment
  1471.         pair.
  1472.  
  1473.         wlong = meml(wseg,wofs);
  1474.  
  1475.         long wch        long returned from memory
  1476.  
  1477.         wseg            Segment value to read from
  1478.  
  1479.         wofs            Offset value to read from
  1480.  
  1481. 16. MODEMSTS    Return the modem status register
  1482.  
  1483.         This function returns the modem status word from bios.
  1484.  
  1485.         wstatus = modemsts(wport);
  1486.  
  1487.         int wstatus     Returned modem status word. Consult the bios tech
  1488.                         ref manual for details.
  1489.  
  1490.         int wport       1 : port 1
  1491.                         2 : port 2
  1492.  
  1493. 17. MOVE        Move bytes from one location to another.
  1494.  
  1495.         This routine does a block move in memory of two variables.
  1496.         It does not handle overlap. This routine only handles near
  1497.         objects in the small model compiler.
  1498.  
  1499.         move(wdestin,wsource,wnum);
  1500.  
  1501.         char *wdestin   Pointer to destin buffer. It can be any type of
  1502.                         pointer.
  1503.  
  1504.         char *wsource   Pointer to source buffer, It can be any type of
  1505.                         pointer.
  1506.  
  1507.         unsigned int
  1508.         wnum            Number of chars to move.
  1509.  
  1510.  
  1511. 18. POKEB       Poke a byte into memory
  1512.  
  1513.         This routine pokes a single byte into a specified memory location
  1514.         by segment,offset.
  1515.  
  1516.         poke(wseg,wofs,wch);
  1517.  
  1518.         int wseg        Segment value to poke into
  1519.  
  1520.         int wofs        Offset value to poke into
  1521.  
  1522.         int wch         Character to poke into memory
  1523.  
  1524.  
  1525. 19. POKEW       Poke a word into memory
  1526.  
  1527.         This routine pokes a single word into a specified memory location
  1528.         by segment,offset.
  1529.  
  1530.         poke(wseg,wofs,wch);
  1531.  
  1532.         int wseg        Segment value to poke into
  1533.  
  1534.         int wofs        Offset value to poke into
  1535.  
  1536.         int wch         Word to poke into memory
  1537.  
  1538. 20. RSPLIST     Create a list from response file
  1539.  
  1540.         This routine creates a linked list of data given a response
  1541.         file on the command line.
  1542.  
  1543.         whead = rsplist(wname);
  1544.  
  1545.         THEAD *whead    Pointer to head of structure. Data type defined
  1546.                         in JAZ.H
  1547.  
  1548.         char *wname     File name to create the list from.
  1549.  
  1550. 21. SOUNDOFF    Turn the speaker off
  1551.  
  1552.         This routine turns the sound off after a call to soundon()
  1553.  
  1554.         soundoff();
  1555.  
  1556. 22. SOUNDON     Turn the speaker on
  1557.  
  1558.         This routine "Plays" the speaker at a specific frequency.
  1559.  
  1560.         soundon(whertz);
  1561.  
  1562.         int whertz      Frequency of pitch. 440 = A
  1563.  
  1564.                         VIDEO/SCREEN/WINDOWING ROUTINES
  1565.                         (ibm or close compatibles only)
  1566.  
  1567. 1.  CLS         Clear the display screen
  1568.  
  1569.         This function clears the display screen to a specified video
  1570.         attribute. This function does not home the cursor. The bit maps
  1571.         for an attribute can be determined based on the following bit
  1572.         pattern:
  1573.  
  1574.         BITS:
  1575.           7    6    5    4       3      2    1    0
  1576.         BLINK,RED,GREEN,BLUE,INTENSITY,RED,GREEN,BLUE
  1577.  
  1578.         The left nibble except for bit 7, pertains to the background,
  1579.         and the right nibble except for bit 3, pertains to the foregound
  1580.         color. These can be combined for any combination.
  1581.  
  1582.         cls(wattribute);
  1583.  
  1584.         int
  1585.         wattribute      The color attribute we want the screen cleared
  1586.                         to.
  1587.  
  1588.         EX.
  1589.           cls(7);               /* clear the screen to normal color */
  1590.  
  1591. 2.  COLOR       Change the global color parameters
  1592.  
  1593.         This allows you to change the global foreground and background
  1594.         colors which are used by many of the windowing related routines.
  1595.         You will find various colors defined in JZSCREEN.H The are:
  1596.  
  1597.         BLACK            0
  1598.         BLUE             1
  1599.         GREEN            2
  1600.         CYAN             3
  1601.         RED              4
  1602.         MAGENTA          5
  1603.         BROWN            6
  1604.         LIGHTGRAY        7
  1605.         DARKGRAY         8
  1606.         LIGHTBLUE        9
  1607.         LIGHTGREEN      10
  1608.         LIGHTCYAN       11
  1609.         LIGHTRED        12
  1610.         LIGHTMAGENTA    13
  1611.         YELLOW          14
  1612.         WHITE           15
  1613.         BLINK          128
  1614.  
  1615.         color(wfore,wback);
  1616.  
  1617.         int wfore       The foreground color you wish to set
  1618.  
  1619.         int wback       The background color you wish to set
  1620.  
  1621. 3. JZAPPEND     Append a window to the window list
  1622.  
  1623.         This routine allows you to add a window onto the window list.
  1624.         It does not matter if the list is empty.
  1625.  
  1626.         savescreen = jzappend(&g_header,wattr,y1,x1,y2,x2,wnum);
  1627.  
  1628.         TWINDOW
  1629.         *savescreen     Returned pointer will point to the window structure
  1630.                         which contains the dimensions of the window, colors
  1631.                         contents, et al.
  1632.  
  1633.         THEADER
  1634.         g_header        This is the header record for the list. It is
  1635.                         initialized in gscreen.h. If you want to use
  1636.                         more than one window list, you must create your
  1637.                         own header record and initialize it yourself.
  1638.  
  1639.         int wattr       This is the color attribute stored for the window.
  1640.  
  1641.         int y1          Upper left row axis
  1642.  
  1643.         int x1          Upper left column axis
  1644.  
  1645.         int y2          Lower right row axis
  1646.  
  1647.         int x2          Lower right column axis
  1648.  
  1649.         int wnum        This is an arbitrary number you assign to the window.
  1650.                         After creating the window list, you can do searches
  1651.                         on the list by number so it would be a good idea to
  1652.                         have a unique number for each window.
  1653.  
  1654. 4. JZBIGLTR     Draw big letters on the screen
  1655.  
  1656.         This routine draws big letters 8 * 8 chars on the screen
  1657.         using the bit mapped character set in rom at address: 0xF000:FA6E.
  1658.         It prints the characters directly to the screen memory for speed.
  1659.  
  1660.         jzbigltr(wch,wrow,wcol,wdrawchr,wattr);
  1661.  
  1662.         int wch         This is the character you want to draw to the screen.
  1663.  
  1664.         int wrow        Row position to write to . 0..24
  1665.  
  1666.         int wcol        Column position to write to 0..79
  1667.  
  1668.         int wdrawchr    This is the character you want to use when drawing.
  1669.                         For example, a good char to use on an IBM is 178
  1670.                         which appears on the screen as '▓'.
  1671.  
  1672.         int wattr       Color attribute for the screen write.
  1673.  
  1674. 5.  JZBIGSTR    Draw a big string to the screen
  1675.  
  1676.         This routine calls jzbigltr to draw a string to the screen.
  1677.  
  1678.         jzbigstr(wstr,wrow,wcol,wdrawchr,wattr);
  1679.  
  1680.         char *wstr      String we want to display on the screen. There is
  1681.                         room for 10 characters on a line.
  1682.  
  1683.         int wrow        Row position to write to . 0..24
  1684.  
  1685.         int wcol        Column position to write to 0..79
  1686.  
  1687.         int wdrawchr    This is the character you want to use when drawing.
  1688.                         For example, a good char to use on an IBM is 178
  1689.                         which appears on the screen as '▓'.
  1690.  
  1691.         int wattr       Color attribute for the screen write.
  1692.  
  1693. 6.  JZCLREOL    Clear to the end of the line
  1694.  
  1695.         This routine clears the line from the given position to the
  1696.         end of the line.
  1697.  
  1698.         jzclreol(wrow,wcol,wattr);
  1699.  
  1700.         int wrow        Row position to clear from
  1701.  
  1702.         int wcol        Column position to clear from
  1703.  
  1704.         int wattr       Attribute to clear line with
  1705.  
  1706. 7.  JZCLRSCR    Clear the current screen WINDOW
  1707.  
  1708.         This routine clears the ACTIVE window with the colors contained
  1709.         in the global color parameters . (You can change these with a
  1710.         call to color())
  1711.  
  1712.         jzclrscr();
  1713.  
  1714. 8.  JZCLRWND    Change the color of a window
  1715.  
  1716.         This routine allows you to change a windows colors without
  1717.         changing it's contents.
  1718.  
  1719.         jzclrwnd(wwindow,wattr);
  1720.  
  1721.         TWINDOW
  1722.         *wwindow        Pointer to window to change color of. Use wsearch()
  1723.                         to return the pointer of a specified window #.
  1724.  
  1725.         int wattr       The new color attribute you wish to change the
  1726.                         window to.
  1727.  
  1728. 9.  JZCLSWND    Close the current window
  1729.  
  1730.         Close a window, restore it's previous contents, and free up the
  1731.         memory taken up by the window struct and it's window buffer.
  1732.  
  1733.         wfound = jzclswnd(wnum);
  1734.  
  1735.         int wfound      Returns 1 if window was found, 0 if not found.
  1736.  
  1737.         int wnum        Number of the window to close.
  1738.  
  1739. 10. JZCPYWND    Copy one window to another.
  1740.  
  1741.         This procedure simply copies the window from the specified window
  1742.         number to the destination window.
  1743.  
  1744.         wcopy = jzcpywnd(worig,wnum);
  1745.  
  1746.         TWINDOW
  1747.         *wcopy          Returns pointer to which a new copy of a window is
  1748.                         assigned. Null if wnum was not found.
  1749.  
  1750.         TWINDOW
  1751.         *worig          Original window to copy.
  1752.  
  1753.         wnum            Window number to assign the copy.
  1754.  
  1755. 11. JZDELETE    Delete a window from the list.
  1756.  
  1757.         Delete the specified window number from the list.
  1758.  
  1759.         jzdelete(wnum);
  1760.  
  1761.         int wnum        The number of the window which you wish to delete.
  1762.  
  1763. 12. JZDRWBOX    Draw a box to the display screen.
  1764.  
  1765.         This procedure draws a box on the screen like so...
  1766.  
  1767.  ┌────────────────────────────────────────────────────────────────────────────┐
  1768.  │                                                                            │
  1769.  │                                                                            │
  1770.  │                                                                            │
  1771.  │                                                                            │
  1772.  │                                                                            │
  1773.  │                                                                            │
  1774.  │                                                                            │
  1775.  │                                                                            │
  1776.  │                                                                            │
  1777.  └────────────────────────────────────────────────────────────────────────────┘
  1778.  
  1779.         jzdrwbox(wrow,wcol,wlen,wwidth,wattr);
  1780.  
  1781.         int wrow        Starting row position of upper left corner of box
  1782.  
  1783.         int wcol        Starting column position of upper left corner of box
  1784.  
  1785.         int wlen        Length of horizontal axis
  1786.  
  1787.         int wwidth      Width of vertical axis
  1788.  
  1789.         int wattr       Color attribute of the window box.
  1790.  
  1791. 13. JZDSPFLD    Display a field on the screen
  1792.  
  1793.         This routine displays a field at a given row,column position and
  1794.         a given color attribute with a given field width. If the string
  1795.         to be displayed has a length of less than the width, then the
  1796.         string is padded to the right with blanks.
  1797.  
  1798.         jzdspfld(wstr,wlen,wrow,wcol,wattr);
  1799.  
  1800.         char *wstr      String to display in the field.
  1801.  
  1802.         int wlen        Max length of the field.
  1803.  
  1804.         int wrow        Row position of the field
  1805.  
  1806.         int wcol        Column position of the field.
  1807.  
  1808.         int wattr       Color attribute of the field.
  1809.  
  1810. 14. JZGETCUR    Get cursor size and position
  1811.  
  1812.         Return the cursor starting and ending scan lines as well as
  1813.         it's absolute position on the screen.
  1814.  
  1815.         jzgetcur(&wrow,&wcol,&wstart,&wend);
  1816.  
  1817.         int wrow        Pointer to returned row position
  1818.  
  1819.         int wcol        Pointer to returned col position
  1820.  
  1821.         int wstart      Pointer to starting scan line of cursor
  1822.  
  1823.         int wend        Pointer to ending scan line of cursor
  1824.  
  1825. 15. JZGETMOD    Get the current screen mode
  1826.  
  1827.         Return the current screen mode.
  1828.  
  1829.         wmode = jzgetmod();
  1830.  
  1831.         int wmode       The returned mode of the screen.
  1832.  
  1833. 16. JZINSTR     Edit a string with editing keys.
  1834.  
  1835.         This routine provides a formatted editing for a field.
  1836.         It is similar in style to DBASE or WORDSTAR.
  1837.  
  1838.         wkey = instr(wstr,wlen,wrow,wcol,wattr,wtime,wkeystr);
  1839.  
  1840.         int wkey        This is the key that was pressed to end the input.
  1841.                         It is usually the return key, but if you have
  1842.                         activated other keys using wkeystr, it would be
  1843.                         the scan code of an active key.
  1844.  
  1845.         int wlen        Max length of the field.
  1846.  
  1847.         int wrow        Starting row of field edit.
  1848.  
  1849.         int wcol        Starting col of field edit.
  1850.  
  1851.         int wattr       Color attribute of edit field.
  1852.  
  1853.         long wtime      Maximum amount of time with no keys
  1854.                         being pressed. Edit will time out after
  1855.                         wtime worth of inactivity and a return
  1856.                         key is returned.
  1857.  
  1858.         char *wkeystr   String of scan codes to terminate the read on.
  1859.                         i.e. If you want to activate the F1 key which
  1860.                         would be "\x3B"
  1861.  
  1862.         EX.
  1863.  
  1864.         #define cESC "\001"
  1865.         #define ESCSCAN 1               /* scan code for escape code */
  1866.         main()
  1867.         {
  1868.           int w = 1,wch;
  1869.           char name[31],street[31],city[16],state[3],zip[6],phone[13];
  1870.  
  1871.           name[0] = 0;
  1872.           street[0] = 0;
  1873.           city[0] = 0;
  1874.           state[0] = 0;
  1875.           zip[0] = 0;
  1876.           phone[0] = 0;
  1877.  
  1878.           do {
  1879.             switch(w) {
  1880.               case 1 : wch = jzinstr(name,30,5,8,(CYAN << 4) + BLUE,60L,cESC);
  1881.                        break;
  1882.               case 2 : wch = jzinstr(street,30,6,8,(CYAN << 4) + BLUE,60L,cESC);
  1883.                        break;
  1884.               case 3 : wch = jzinstr(city,15,7,8,(CYAN << 4) + BLUE,60L,cESC);
  1885.                        break;
  1886.               case 4 : wch = jzinstr(state,2,8,8,(CYAN << 4) + BLUE,60L,cESC);
  1887.                        break;
  1888.               case 5 : wch = jzinstr(zip,5,9,8,(CYAN << 4) + BLUE,60L,cESC);
  1889.                        break;
  1890.               case 6 : wch = jzinstr(phone,12,10,8,(CYAN << 4) + BLUE,60L,cESC);
  1891.                        break;
  1892.             }
  1893.  
  1894.             switch (wch) {
  1895.               case CTRL_X :
  1896.               case CTRL_M : w = min(LAST,w+1);
  1897.                             break;
  1898.               case CTRL_E : w = max(FIRST,w-1);
  1899.                             break;
  1900.               case PGDN   : w = LAST;
  1901.                             break;
  1902.               case PGUP   : w = FIRST;
  1903.                             break;
  1904.               case ESCSCAN: return;
  1905.             }
  1906.           } while (-1);
  1907.         }
  1908.  
  1909. 17. JZINTWND    Initialize global window parms
  1910.  
  1911.         Initialize the various window parameters:
  1912.  
  1913.         jzintwnd(wrow1,wcol1,wrow2,wcol2,wattr)
  1914.  
  1915.         int wrow1       Set global upper left row position
  1916.  
  1917.         int wcol1       Set global upper right column position
  1918.  
  1919.         int wrow2       Set global lower right row position
  1920.  
  1921.         int wcol2       Set global lower right column position
  1922.  
  1923.         int wattr       Color attribute to set the window to.
  1924.  
  1925. 18. JZLOCCUR    Position the cursor
  1926.  
  1927.         This function positions the cursor on the display screen.
  1928.         It is an absolute cursor positioning, independant of window
  1929.         dimension.
  1930.  
  1931.         jzloccur(wrow,wcol);
  1932.  
  1933.         int wrow        Row position to set cursor to . 0..24
  1934.  
  1935.         int wcol        Column position to set cursor to . 0..79
  1936.  
  1937. 19. JZMENU      Display a menu on the screen.
  1938.  
  1939.         This routine displays a menu and returns the users choice. The
  1940.         style of menu is similar to the lotus menus where you use the
  1941.         arrow keys to scroll through the choices and select an item
  1942.         by pressing <enter> when that item is highlighted. This routine
  1943.         saves the users screen so that when the item is selected, the
  1944.         screen is restored to it's previous contents and the cursor is
  1945.         brought back to it's original position.
  1946.  
  1947.         wchoice = jzmenu(wlist,wfore,wback,wkeys)
  1948.  
  1949.         int wchoice     Returned value of the choice.
  1950.                         0 = option 1
  1951.                         1 = option 2
  1952.                         2 = option 3
  1953.                         etc..
  1954.  
  1955.         char **wlist    Pointer to a pointer of strings to display on
  1956.                         the menu.
  1957.  
  1958.         int wfore       Foreground color of menu
  1959.  
  1960.         int wback       Background color of menu
  1961.  
  1962.         EX.
  1963.  
  1964.           char *wlist[] = {
  1965.           "THIS IS A TEST",
  1966.           "OF THE EMERGENCY",
  1967.           "BROADCAST SYSTEM",
  1968.           "IF THIS WERE A",
  1969.           "REAL EMERGENCY" ,
  1970.           "YOU WOULD HAVE",
  1971.           "BEEN NOTIFIED..." ,
  1972.           "WHY AM I TYPING THIS?",
  1973.           ""
  1974.           };
  1975.  
  1976.           #include <jzscreen.h>
  1977.           #include <gscreen.h>
  1978.  
  1979.           #define wkeystr "\x3B\x01"      /* scan codes for F1 and ESC */
  1980.           #define ESC 1                   /* scan code for ESC */
  1981.           #define F1  0x3b                /* scan code for F1 */
  1982.  
  1983.           main()
  1984.           {
  1985.             int wchoice;
  1986.  
  1987.             wchoice = jzmenu(wlist,WHITE,BLUE,wkeystr);
  1988.  
  1989.             switch(wchoice) {
  1990.               case ESC : printf("\nThe Esc key was pressed");
  1991.                          break;
  1992.               case F1  : printf("\nThe F1 key was pressed");
  1993.                          break;
  1994.               default  : printf("\nYou picked item %d",wchoice);
  1995.                          break;
  1996.             }
  1997.           }
  1998.  
  1999. 20. JZMOVWND    Move a window on the screen.
  2000.  
  2001.         This routine moves a windows position on the screen. It does
  2002.         NOT restore the previous contents of the original position.
  2003.  
  2004.         jzmovwnd(wptr,wrow,wcol);
  2005.  
  2006.         TWINDOW
  2007.         *wptr           Pointer to window structure to move.
  2008.  
  2009.         wrow            Row position to move window to
  2010.  
  2011.         wcol            Col position to move window to.
  2012.  
  2013. 21. JZOPNWND    Open a window on the screen
  2014.  
  2015.         This routine opens a screen window, drawing the box around the window,
  2016.         clearing the window screen to the selected attributes, and adding
  2017.         the window structure to the window list.
  2018.  
  2019.         wwindow = jzopnwnd(wnum,wrow,wcol,wlen,wwidth,wfore,wback);
  2020.  
  2021.         TWINDOW
  2022.         *wwindow        Returned pointer to window structure just created
  2023.  
  2024.         int wnum        Number to save for this window. This can be set
  2025.                         to any number but you should have a unique number
  2026.                         for each window you create.
  2027.  
  2028.         int wrow        Starting upper left row position of window.
  2029.  
  2030.         int wcol        Starting upper left col position of window
  2031.  
  2032.         int wwidth      Horizontal length of window
  2033.  
  2034.         int wlen        Vertical Length of window
  2035.  
  2036.         int wfore       Foreground color of window
  2037.  
  2038.         int wback       Background color of window
  2039.  
  2040. 22. JZPGECLR    Clear the given page
  2041.  
  2042.         This routine clears the given page to the specified color attribute.
  2043.  
  2044.         jzpgeclr(wpage,wattr);
  2045.  
  2046.         int wpage       A valid page number. On the CGA adapter card, this
  2047.                         would be 0..3. There is only one page on the Mono
  2048.                         card.
  2049.  
  2050.         int wattr       Color attribute to clear the screen to.
  2051.  
  2052. 23. JZPGEPRN    Print directly to a page
  2053.  
  2054.         This routine prints a string directly to video memory on
  2055.         the specified page number. This should not be used on a
  2056.         monochrome adapter.
  2057.  
  2058.         jzpgeprn(wstr,wrow,wcol,wattr,wpage);
  2059.  
  2060.         char *wstr      String pointer to print to the given page
  2061.  
  2062.         int wrow        Row position relative to page top to print to
  2063.  
  2064.         int wcol        Col position relative to page top to print to
  2065.  
  2066.         int wattr       Color attribute use when printing.
  2067.  
  2068.         int wpage       A valid page number. 0..3
  2069.  
  2070. 24. JZPLOT      Plot a dot to the graphics screen
  2071.  
  2072.         This function plots a pixal to the color graphics screen.
  2073.  
  2074.         jzplot(wrow,wcol,wattr);
  2075.  
  2076.         int wrow        Row position of pixel to plot
  2077.  
  2078.         int wcol        Col position of pixel to plot
  2079.  
  2080.         int wattr       Color attribute to plot dot with
  2081.  
  2082. 25. JZREDCHR    Read a char and attribute from screen
  2083.  
  2084.         This function reads a character and attribute from the current
  2085.         cursor position
  2086.  
  2087.         jzredchr(&wch,&wattr);
  2088.  
  2089.         int wch         Pointer to the returned character.
  2090.  
  2091.         int wattr       Pointer to the returned attribute
  2092.  
  2093. 26. JZREDSCR    Read a string from the screen.
  2094.  
  2095.         This function returns a string from a given screen position. It
  2096.         does not return attributes.
  2097.  
  2098.         jzredscr(wstr,wrow,wcol,wlen);
  2099.  
  2100.         char *wstr      Pointer to the string to be returned.
  2101.  
  2102.         int wrow        Starting row position to read from screen.
  2103.  
  2104.         int wcol        Starting col position to read from screen.
  2105.  
  2106.         int wlen        Length of string to read from screen.
  2107.  
  2108. 27. JZRSTWND    Restore a windows contents
  2109.  
  2110.         This routine restores a windows contents without removing the
  2111.         window from the window list.
  2112.  
  2113.         jzrstwnd(wwindow);
  2114.  
  2115.         TWINDOW
  2116.         *wwindow        Pointer to window to restore contents of
  2117.  
  2118. 28. JZSAVWND    Save a windows contents
  2119.  
  2120.         Save a windows contents into an existing window structure. The
  2121.         window buffer is NOT resized so if you change sizes of windows,
  2122.         be careful to realloc() the window buffer before calling this
  2123.         routine. This routine is useful during window moves.
  2124.  
  2125.         jzsavwnd(wwindow);
  2126.  
  2127.         TWINDOW
  2128.         *wwindow        Pointer to existing window struct to save.
  2129.  
  2130. 29. JZSCRLDN    Scroll a window down
  2131.  
  2132.         This routine calls bios to scroll a window down on the screen.
  2133.  
  2134.         jzscrldn(wyx1,wyx2,wnum,wattr);
  2135.  
  2136.         int wyx1        This integer contains the upper left row position
  2137.                         of the window in the high byte and the upper left
  2138.                         column position in the low byte.
  2139.  
  2140.         int wyx2        This integer contains the lower right row position
  2141.                         of the window in the high byte and the lower right
  2142.                         column position in the low byte.
  2143.  
  2144.         int wnum        Number of lines to scroll. At maximum, this number
  2145.                         should be Y2 - Y1. Specify 0 to scroll the whole
  2146.                         window, effectively clearing it. Specifying :
  2147.                         Y2 - Y1 + 1, which is the actual number of lines
  2148.                         in the window will garble up the screen on an
  2149.                         IBM pc.
  2150.  
  2151. 30. JZSCRLUP    Scroll a window up
  2152.  
  2153.         This routine calls bios to scroll a window up on the screen.
  2154.  
  2155.         jzscrlup(wyx1,wyx2,wnum,wattr);
  2156.  
  2157.         int wyx1        This integer contains the upper left row position
  2158.                         of the window in the high byte and the upper left
  2159.                         column position in the low byte.
  2160.  
  2161.         int wyx2        This integer contains the lower right row position
  2162.                         of the window in the high byte and the lower right
  2163.                         column position in the low byte.
  2164.  
  2165.         int wnum        Number of lines to scroll. At maximum, this number
  2166.                         should be Y2 - Y1. Specify 0 to scroll the whole
  2167.                         window, effectively clearing it. Specifying :
  2168.                         Y2 - Y1 + 1, which is the actual number of lines
  2169.                         in the window will garble up the screen on an
  2170.                         IBM pc.
  2171.  
  2172. 31. JZSCROFF    Disable the video screen (DO NOT USE WITH HERCULES CARDS)
  2173.  
  2174.         This disables the video signal to the screen, blanking (but not
  2175.         clearing) the display screen. This routine has been known to
  2176.         cause hardware damage to certain non - ibm video cards. I am
  2177.         not responsible if this happens to you!
  2178.  
  2179.         jzscroff();
  2180.  
  2181. 32. JZSCRON     Enable the video screen (DO NOT USE WITH HERCULES CARDS)
  2182.  
  2183.         This routine enables the video signal to the screen. Restoring
  2184.         it's previous contents.
  2185.         it's previous contents. This routine has been known to
  2186.         cause hardware damage to certain non - ibm video cards. I am
  2187.         not responsible if this happens to you!
  2188.  
  2189.         jzscron();
  2190.  
  2191. 33. JZSCRPRN    Print directly to video memory
  2192.  
  2193.         This routine allows you to print directly to video memory
  2194.         specifying row,column and color. It also avoids snow on the
  2195.         ibm CGA card. It is a very fast routine, about 10 times faster
  2196.         than printf().
  2197.  
  2198.         jzscrprn(wstr,wrow,wcol,wattr);
  2199.  
  2200.         char *wstr      String to print to screen.
  2201.  
  2202.         int wrow        Row to print to
  2203.  
  2204.         int wcol        Column to print to
  2205.  
  2206.         int wattr       Color attribute to use when printing.
  2207.  
  2208. 34. JZSETCUR    Set the cursors size
  2209.  
  2210.         This routine allows you to adjust the cursors starting and
  2211.         ending scan lines. The cursor is mapped as follows:
  2212.  
  2213. Default Scan         Monochrome                     Color
  2214.  
  2215.                 1  . . . . . . . .             . . . . . . . .
  2216.                 2  . . . . . . . .             . . . . . . . .
  2217.                 3  . . . . . . . .             . . . . . . . .
  2218.                 4  . . . . . . . .             . . . . . . . .
  2219.                 5  . . . . . . . .             . . . . . . . .
  2220.                 6  . . . . . . . .             . . . . . . . .
  2221.                 7  . . . . . . . .    Start    ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  2222.                 8  . . . . . . . .    End      ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  2223.                 9  . . . . . . . .
  2224.                10  . . . . . . . .
  2225. Start          11  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  2226. End            12  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  2227.  
  2228.  
  2229.         jzsetcur(wstart,wend);
  2230.  
  2231.         int wstart      Starting scan line of cursor
  2232.  
  2233.         int wend        Ending scan line of cursor
  2234.  
  2235. 35. JZSETMDE    Set the screen mode
  2236.  
  2237.         Set the current screen mode.
  2238.  
  2239.         jzsetmde(wmode);
  2240.  
  2241.         int wmode       Valid screen mode.
  2242.  
  2243. 36. JZSETPGE    Activate a page
  2244.  
  2245.         This function activates a page of video memory.
  2246.  
  2247.         jzsetpge(wpage);
  2248.  
  2249.         int wpage       A page of CGA memory to activate. 0..3
  2250.  
  2251. 37. JZWNDASN    Assign values to a window structure
  2252.  
  2253.         This internal routine (used by jzappend) is a convenient way
  2254.         of assigning values to a window structure.
  2255.  
  2256.         jzwndasn(wwindow,wrow,wcol,wattr,wnum,wy1,wx1,wy2,wx2);
  2257.  
  2258.         TWINDOW
  2259.         *wwindow        Pointer to window to assign values to
  2260.  
  2261.         wrow            Row position to assign
  2262.  
  2263.         wcol            Col position to assign
  2264.  
  2265.         wattr           Attribute to assign
  2266.  
  2267.         wnum            Window number to assign
  2268.  
  2269.         wy1             Upper left row to assign
  2270.  
  2271.         wx1             Upper left col to assign
  2272.  
  2273.         wy2             Lower right row to assign
  2274.  
  2275.         wx2             Lower right col to assign
  2276.  
  2277. 38. JZWRITE     Write to the current window
  2278.  
  2279.         This function writes a string to the current window in the
  2280.         using the global color and window parameters.
  2281.  
  2282.         jzwrite(fstr);
  2283.  
  2284.         char *wstr      String to write
  2285.  
  2286. 39. JZWRTCHR    Write a char to the screen using bios
  2287.  
  2288.         This function writes a char to the screen using bios.
  2289.  
  2290.         jzwrtchr(wch,wattr,wnum);
  2291.  
  2292.         int wch         Character to write
  2293.  
  2294.         int wattr       Color attribute of char
  2295.  
  2296.         int wnum        Number of copies to write
  2297.  
  2298. 40.  JZWRTSTR   Write a string using bios
  2299.  
  2300.         This routine writes a string to the screen using the bios
  2301.         jzwrtchr call.
  2302.  
  2303.         jzwrtstr(wstr,wrow,wcol,wattr);
  2304.  
  2305.         char *wstr      String to write to screen.
  2306.  
  2307.         int wrow        Row to write to
  2308.  
  2309.         int wcol        Column to write to
  2310.  
  2311.         int wattr       Color attribute to use when writing.
  2312.  
  2313. 41. LOCATE      Position the cursor in the window
  2314.  
  2315.         This routine positions the cursor relative to the active window.
  2316.  
  2317.         locate(wrow,wcol);
  2318.  
  2319.         int wrow        Row position of cursor in the window
  2320.  
  2321.         int wcol        Col position of cursor in the window
  2322.  
  2323. 42. MOVEATTR    Move attributes to a screen window
  2324.  
  2325.         This routine move attributes only to a screen window which
  2326.         allows you to change the color of a window without affecting
  2327.         it's contents and avoiding snow.
  2328.  
  2329.         moveattr(wscreenseg,woffset,wnumrows,wnumcols,wattr);
  2330.  
  2331.         int
  2332.         wscreenseg      Segment address of active screen. Should be
  2333.                         0xb800 for color, 0xb000 for mono.
  2334.  
  2335.         int woffset     Offset of screen position. Computed by
  2336.                         row * 160 + (col << 1)
  2337.  
  2338.         int wnumrows    Number of rows in window
  2339.  
  2340.         int wnumcols    Number of cols in window
  2341.  
  2342.         int wattr       Attribute color of window
  2343.  
  2344. 43. MOVEB       Move a screen window to a buffer
  2345.  
  2346.         Internal routine (see jzsavwnd) to move screen memory to a
  2347.         buffer avoiding snow.
  2348.  
  2349.         moveb(wscreenseg,woffset,wbufseg,wbufofs,wnumrows,wnumcols);
  2350.  
  2351.         int
  2352.         wscreenseg      Segment address of active screen. Should be
  2353.                         0xb800 for color, 0xb000 for mono.
  2354.  
  2355.         int woffset     Offset of screen position. Computed by
  2356.                         row * 160 + (col << 1)
  2357.  
  2358.         int wbufseg     Segment address of destination buffer. getds()
  2359.                         can be used here usually.
  2360.  
  2361.         int wbufofs     Offset address of buffer.
  2362.  
  2363.         int wnumrows    Number of rows in window
  2364.  
  2365.         int wnumcols    Number of cols in window
  2366.  
  2367. 44. MOVES       Move a buffer to screen memory
  2368.  
  2369.         This routine moves a buffer to a screen window avoiding snow.
  2370.  
  2371.         moves(wbufseg,wbufofs,wscreenseg,woffset,wnumrows,wnumcols);
  2372.  
  2373.         int wbufseg     Segment address of destination buffer. getds()
  2374.                         can be used here usually.
  2375.  
  2376.         int wbufofs     Offset address of buffer.
  2377.  
  2378.         int
  2379.         wscreenseg      Segment address of active screen. Should be
  2380.                         0xb800 for color, 0xb000 for mono.
  2381.  
  2382.         int woffset     Offset of screen position. Computed by
  2383.                         row * 160 + (col << 1)
  2384.  
  2385.         int wnumrows    Number of rows in window
  2386.  
  2387.         int wnumcols    Number of cols in window
  2388.  
  2389. 45. WINDOW      Set the window dimensions
  2390.  
  2391.         This routine allows you to set the global window dimensions which
  2392.         are used for the various window write, and cursor positioning
  2393.         routines.
  2394.  
  2395.         window(wrow1,wcol1,wrow2,wcol2);
  2396.  
  2397.         int wrow1       Value to set upper left row
  2398.  
  2399.         int wcol1       Value to set upper left col
  2400.  
  2401.         int wrow2       Value to set lower right row
  2402.  
  2403.         int wcol2       Value to set lower right col
  2404.  
  2405. 46. WPRINTF     Printf function relative to window
  2406.  
  2407.         This routine provides for a printf that allows color and relativity
  2408.         to the current window dimension. It handles all data types except
  2409.         float. It does not allow redirection.
  2410.  
  2411.         wprintf("\n%d %c %s",wint,wchar,wstring);
  2412.  
  2413.         int wint        Sample integer
  2414.  
  2415.         int wchar       Sample char
  2416.  
  2417.         int wstring     Sample string
  2418.  
  2419. 47. WSEARCH     Search for a window
  2420.  
  2421.         Search for a specified window number and return it's pointer
  2422.  
  2423.         wptr = wsearch(wnum);
  2424.  
  2425.         TWINDOW
  2426.         *wptr           Returned pointer to window structure. Should be
  2427.                         checked for null in case window is not found
  2428.  
  2429.         int wnum        Number of the window to search for.
  2430.  
  2431.                                 KEYBOARD ROUTINES
  2432.  
  2433. 1.  JZINKEY     Return the char and scan code of a key
  2434.  
  2435.         This routine waits until a key is pressed and returns
  2436.         it's character and scan code. The character can be
  2437.         examined and if it is 0, the key was one of the special
  2438.         function keys, cursor keys, alt sequences, or shift sequences.
  2439.  
  2440.         wch = jzinkey(&wscan);
  2441.  
  2442.         int wch         Returned character that was pressed
  2443.  
  2444.         int wscan       Scan code of character that was pressed.
  2445.  
  2446. 2.  JZKEYPRS    Return 1 if a key is waiting
  2447.  
  2448.         This routine determines whether a key was pressed by calling
  2449.         a bios function to see whether a key is in the keyboard buffer.
  2450.  
  2451.         wkeypressed = jzkeyprs();
  2452.  
  2453.         int
  2454.         wkeypressed     Returns 1 if a key is pressed, otherwise 0
  2455.  
  2456. 3.  JZKEYSTS    Return the keyboard status record
  2457.  
  2458.         This routine returns a keyboard status record which can be looked
  2459.         at to determine which special keys are down such as insert, caps-lock,
  2460.         num-lock etc.
  2461.  
  2462.         jzkeysts(&wkey);
  2463.  
  2464.         TKEY wkey       Pointer to record containing key status info.
  2465.  
  2466.  
  2467.         EX.
  2468.  
  2469.           #include <jaz.h>
  2470.  
  2471.         main()
  2472.         {
  2473.           KEYSTATE wkey;
  2474.  
  2475.           jzkeysts(&wkey);      /* get key status */
  2476.  
  2477.           if (wkey.s.capslock)
  2478.             printf("\nCaps lock is on!");
  2479.         }
  2480.  
  2481. 4.  JZPUTKBD    Write chars to the keyboard buffer
  2482.  
  2483.         This function is capable of writing a string to the keyboard
  2484.         buffer. A maximum of 16 chars will be written.
  2485.  
  2486.         jzputkbd(wstr);
  2487.  
  2488.         char *wstr      String of chars to be written. If an extended char
  2489.                         is to be written to the buffer, proceed it's scan code
  2490.                         with a \xFF. i.e. jzputkbd("\xFF\x3B") would put
  2491.                         the F1 key in the buffer. (0x3b is the scan code for
  2492.                         the F1 key)
  2493.  
  2494.                                MISC MACROS
  2495.  
  2496. 1. LPOINTER     Gain access to far memory locations.    (JAZ.H)
  2497.  
  2498.         This macro allows access to far memory locations for useful
  2499.         in hardware intensize applications.
  2500.  
  2501.         wch = LPOINTER(char , wseg , wofs);
  2502.  
  2503.         char *wch       Pointer to whatever type is specified
  2504.  
  2505.         type char       This would be any valid type
  2506.  
  2507.         int wseg        Segment value to get pointer for
  2508.  
  2509.         int wofs        Offset value to get pointer for
  2510.  
  2511. 2.  MEMB        Gain access to far char locations       (JAZ.H)
  2512.  
  2513.         This macro allows access to far memory locations.
  2514.  
  2515.         wch = MEMB(wseg,wofs);
  2516.  
  2517.         int wch         Value returned from pointer
  2518.  
  2519.         int wseg        Segment value to point to
  2520.  
  2521.         int wofs        Offset value to point to
  2522.  
  2523. 3.  MEMW        Gain access to far word locations       (JAZ.H)
  2524.  
  2525.         This macro allows access to far memory locations.
  2526.  
  2527.         wch = MEMW(wseg,wofs);
  2528.  
  2529.         int wch         Value returned from pointer
  2530.  
  2531.         int wseg        Segment value to point to
  2532.  
  2533.         int wofs        Offset value to point to
  2534.  
  2535. 4.  MEML        Gain access to far long locations       (JAZ.H)
  2536.  
  2537.         This macro allows access to far memory locations.
  2538.  
  2539.         wch = MEML(wseg,wofs);
  2540.  
  2541.         long wch         Value returned from pointer
  2542.  
  2543.         int wseg        Segment value to point to
  2544.  
  2545.         int wofs        Offset value to point to
  2546.  
  2547. 5. SCROFS       Convert row and column position to a screen offset (JZSCREEN.H)
  2548.  
  2549.         This macro converts row and column to an absolute screen offset.
  2550.  
  2551.         wofs = SCROFS(wrow,wcol);
  2552.  
  2553.         int wofs        Returned offset
  2554.  
  2555.         int wrow        row position
  2556.  
  2557.         int wcol        Column position
  2558.  
  2559. 6.  MKATTR      Make a color attribute given fore and back ground. (JZSCREEN.H)
  2560.  
  2561.         This macro converts a foreground and background color to a video
  2562.         attribute useful in many of the screen functions.
  2563.  
  2564.         wattr = MKATTR(wback,wfore);
  2565.  
  2566.         int wattr       Returned video attribute
  2567.  
  2568.         int wback       Background color
  2569.  
  2570.         int wfore       Foreground color
  2571.  
  2572. 7.  CNTCOL      Centering fields  (JZSCREEN.H)
  2573.  
  2574.         This macro returns a column position with which to center a string
  2575.         in a given width.
  2576.  
  2577.         wcol = CNTCOL(wstr,wwidth);
  2578.  
  2579.         int wcol        Returned centered column
  2580.  
  2581.         char *wstr      String to provide centered column for
  2582.  
  2583.         int wwidth      Width of field.
  2584.  
  2585. 8.  CLEARKBD    Clear the keyboard buffer  (KEYS.H)
  2586.  
  2587.         This macro clears the keyboard buffer
  2588.  
  2589.         CLEARKBD
  2590.  
  2591. 9.  MSDOS       Provide an msdos function.      (JAZ.H)
  2592.  
  2593.         This macro simulates the msdos call like in Turbo Pascal.
  2594.  
  2595.         MSDOS(&wreg);
  2596.  
  2597.         TREG wreg       Pointer to structure of a register record.
  2598.  
  2599.                                 DEMO PROGRAMS
  2600. Note:
  2601.   When compiling and linking these routines, make sure to use a compile spec
  2602.   similar to this :
  2603.   \msc\msc /Ox /Ze /Zp /I c:\msc\jaz %1/DLINT_ARGS;
  2604.  
  2605.   The "/Ze","/Zp" are absolutely neccessary for many of these programs.
  2606.  
  2607.   The link spec is not as critical (see link.bat) but many of the routines
  2608.   require a larger stack than the default. (Especially the interrupt handlers)
  2609.   Failure to use a large enough stack will result in the system hanging in
  2610.   many cases.
  2611.   -Jaz
  2612.  
  2613. 1.  BADSECT     Check and List bad sectors on A:
  2614.  
  2615. 2.  COPYFILE    Copy one file to another. Wildcards are supported.
  2616.                 The syntax is COPYFILE <source spec> <destin spec>
  2617.  
  2618. 3.  DIRLST      Demonstration of a disk directory places in a binary
  2619.                 tree and printed out. Use "/st:12000" when linking
  2620.  
  2621. 4.  JAZPRINT    Print multiple files with formatting. Demo of directory
  2622.                 routines as well as buffer stream printing.
  2623.                 formatting options.
  2624.        -d specifies double strike printing
  2625.        -e specifies emphasized printing
  2626.        -t specifies title of document + time and date
  2627.        -w specifies wide (compressed) listing
  2628.        -n specifies to number the lines
  2629.        -u specifies user chars to send (in hex). i.e jazprint *.* -u 1b471b45
  2630.        -mn specifies multiple copies where n is the number of copies
  2631.  
  2632. 5.  JZBACKGR    This program plays a dumb tune in the background of a
  2633.                 DBASE like editing screen. It is a good demo of interrupt
  2634.                 handlers, Input screens, and the sound routines.
  2635.  
  2636. 6.  JZBIGLTR    Demonstration of big printing.
  2637.  
  2638. 7.  JZCHKDSK    Program is similar to chkdsk but with many option. It will
  2639.                 report on contiguous files/non contiguous files, bad sectors,
  2640.                 etc. Link with "/ST:12000"
  2641.                 Usage: JZCHKDSK <Options> <Path>
  2642.                 Options: -c   List contiguous files
  2643.                          -n   List non - contiguous files only
  2644.                          -q   Quiet mode. Don't list files at all
  2645.                          -b   List Bad Sectors
  2646.  
  2647. 8.  JZCLOCK     This program puts a resident clock on the screen in the upper
  2648.                 right hand corner. It takes up a LOT of memory but is mainly
  2649.                 a demo just to prove it can be done in MS-C. When I have 4.0,
  2650.                 I will probably be able to significantly reduce the size of
  2651.                 the resident code. Must be linked with "/ST:12000"
  2652.  
  2653. 9.  JZDIR       Incomplete demo of directly reading disk directory sectors.
  2654.  
  2655. 10. JZDIRLST    Demo of sorted directory with binary tree. Link with
  2656.                 "/st:12000"
  2657.  
  2658. 11. JZEDTCHR    Demonstration of how to access the character set in rom.
  2659.                 This routine allows you to edit and change the upper
  2660.                 128 characters and install a pointer to your buffer. Use
  2661.                 font.chr (a sample script char set) and have fun. Link
  2662.                 with "/st:12000"
  2663.  
  2664. 12. JZFIND      This program finds files across sub-directories. It supports
  2665.                 wild-cards in the file searches. i.e. jzfind *.doc
  2666.  
  2667. 13. JZMENU      Incomplete demo of menu routines and menu drivers.
  2668.  
  2669. 14. MENU        Simple demo of the jzmenu() function.
  2670.  
  2671. 15. JZPSHDIR    Demonstration of the jzpshdir,jzpopdir. This routine expects
  2672.                 an A drive, B drive and C drive with the b:drive having a
  2673.                 subdirectory named test. This routine simply does a few
  2674.                 directory changes , pushing the dirs beforehand and poping
  2675.                 them back to change directories and drives.
  2676.  
  2677. 16. JZPUSH      Simple demo of data conversion using jzpush and jzpop.
  2678.  
  2679. 17. JZPUTKBD    Demonstration of the jzputkbd routine allowing characters
  2680.                 to be "written" to the keyboard buffer on IBM and close
  2681.                 compatibles.
  2682.  
  2683. 18. JZSCREEN    Demo of big letters. Prints command line on screen.
  2684.  
  2685. 19. JZSEARCH    Search multiple files for the occurance of strings.
  2686.  
  2687.            Usage JZSEARCH [-uwcr] [filespec] [search string\\replace string]
  2688.            Options are as follows:\n");
  2689.            -u          Uppercase (Ignores case on search)
  2690.            -c          Display files on console
  2691.            -w          Whole words only. "MEM" won't be found in "MEMORY"
  2692.            -r          Replace string if found. Syntax for this is:"
  2693.            -p          Prompt for change before replacing
  2694.  
  2695. 20. JZSETATR    Allows setting attributes of files. Supports wildcards.
  2696.                 Syntax is JZSETATR <file spec> <attribute>
  2697.  
  2698. 21. POPDIR      Stand alone popdir program. Uses a virtual stack technique.
  2699.  
  2700. 22. PUSHDIR     Stand alone pushdir program. Uses a virtual stack technique.
  2701.  
  2702. 23. RENFILE     Allows renaming of files across subdirecties. Allows
  2703.                 wildcards. This one is not thouroghly tested yet so
  2704.                 make sure you have a backup before proceeding here!
  2705.  
  2706.                 USAGE:    renfile <old path\\old name> <new path>
  2707.  
  2708. 24. SCREEN      Demo of various screen and window related functions.
  2709.                 This program is obsolete. Do NOT compile it. Run only
  2710.                 if you received the executable along with the source.
  2711.                 Calling conventions of many of the routines have changed
  2712.                 since this was written.
  2713.  
  2714. 25. TRUNCFIL    Demo program to truncate a file. You specify the file name,
  2715.                 the original size, and the new size.
  2716.  
  2717. 26. VIEW        This is a read only edit that saves the users screen before
  2718.                 running. This means when you exit, your screen will appear
  2719.                 just as it did before this program was run.
  2720.  
  2721. 27. WINDOW      This program demonstrates many of the screen and windowing
  2722.                 functions available in the system. However the window moving
  2723.                 is not very smooth at this point. I will be working on that
  2724.                 very soon.
  2725.  
  2726.  
  2727.  
  2728.